package com.whc.message.controller;


import com.whc.message.domain.entity.Message;
import com.whc.message.domain.vo.MessageVo;
import com.whc.message.service.MessageService;
import com.whc.common.domain.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Api(tags = "消息信息")
@RestController
@RequestMapping("/client/message")
@Slf4j
public class MessageController {
    @Autowired
    private MessageService messageService;

    @ApiOperation("查询所有消息")
    @GetMapping("/getAll")
//    @PreAuthorize("hasAuthority('user')")
    public Result<List<MessageVo>> getALl(@RequestParam("senderId") Long senderId, @RequestParam("accepterId") Long accepterId){
        List<MessageVo> messageVos = messageService.getAll(senderId, accepterId);
        return Result.success(messageVos);
    }

    @ApiOperation("添加消息")
    @PostMapping
//    @PreAuthorize("hasAuthority('user')")
    public Result addOne(@RequestBody Message message){
        messageService.add(message);
        return Result.success();
    }
}
